package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Process;
import com.qidianit.mes.pojo.pro.ProcessStep;
import com.qidianit.mes.pro.service.ProcessService;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/processStep")
@CrossOrigin
public class ProcessStepController {
    @Autowired
    private ProcessStepService processStepService;
    @GetMapping("page")
    public Result<PageInfo<ProcessStep>>
    list(ProcessStep processStep, @RequestParam(defaultValue = "1")int pageNum,
                            @RequestParam(defaultValue = "10")int size){
        return processStepService.selectList(processStep,pageNum,size);
    }

    @GetMapping("/get/{id}")
    public Result<ProcessStep> selectById(@PathVariable("id") Long id){
        return processStepService.selectById(id);
    }

    @PostMapping("/add")
    public Result<ProcessStep> saveProcessStep(@RequestBody ProcessStep processStep){
        return processStepService.saveProcessStep(processStep);
    }

    @PutMapping("/update")
    public Result<ProcessStep> updateProcessStep(@RequestBody ProcessStep processStep){
        return processStepService.updateById(processStep);
    }

    @DeleteMapping("/delete/{id}")
    public Result deletedById(@PathVariable("id") Long id){
        return processStepService.deleteById(id);
    }
}
